<template>
    <!-- 这个是测试版 -->
    <div class="newsinfo-container">
        <h3 class="title">我是新闻</h3>
        <div class="subtitle">
            <span>发表时间：2018-25-16</span>
            <span>点击1次</span>
        </div>

        <hr>
        <div class="content">
            省略1千行字
            <img src="../../images/menu1.png" alt="">
            <img src="../../images/menu2.png" alt="">
        </div>
        <!-- 评论列表组件 -->
        <comment-box :id="this.id"></comment-box>
    </div>
    <!-- 数据渲染版 -->
    <!-- <div class="newsinfo-container">
        <h3 class="title">{{ newsinfo.title }}</h3>
        <p class="subtitle">
            <span>发表时间：{{ newsinfo.add_time }}</span>
            <span>点击{{ newsinfo.click }}次</span>
        </p>

        <hr>
        <div class="content" v-html="newsinfo.content"></div>
        <comment-box :id="this.id"></comment-box>

    </div> -->
</template>
<script>
    import comment from "../subcomponents/comment.vue"
    import { Toast } from "mint-ui"
    export default {
        data(){
            return {
                //胡来的数据是数组，但是只有一个元素，所以直接创建对象
                newsinfo: {},
                id: this.$route.parmas.id     //根据路由匹配参数获得id挂载到data上方便调用
            }
        },
        created(){
           // this.getNewsInfo()
        },
        methods: {
            getNewsInfo(){
                this.$http.get("api/getnew/"+this.id).then(result=>{
                    if(rsult.body.status ===0){
                        this.newsinfo = result.body.message[0];
                    }else {
                        Toast("获取新闻失败了")
                    }
                })
            },
            
        },
        components: {
            "comment-box": comment
        }
    }
</script>

<style lang="scss" scoped>
// scoped注意点在于不能加，加上影响返回图片数据的大小
    .newsinfo-container {
         padding: 0 4px;
        .title {
            font-size: 16px;
            color: red;
            text-align: center;
            margin: 15px 0px;
        }
        .subtitle {
            display: flex;
            justify-content: space-between;
            font-size: 13px;
            color: #226aff;
        
        }
        .content {
         
            img {
                width: 100%;
            }
        }
    }
</style>
